package alexAI;

/**
 * Class that allows you to create a timer to evaluate how much time a certain process takes.
 * @author Mellyn
 *
 */
public class Timer {
	
	private long startTime, endTime;
	static Timer myTimer = null;
	
	 protected Timer()
	 {
	  // prevent instantiation
	 }
	
	public static Timer getInstance() {
		if(myTimer == null) 
			myTimer = new Timer();
		return myTimer;
	}
	
	/**
	 * Starts the timer
	 */
	public void startTimer() {
		startTime = System.nanoTime();
	}
	/**
	 * Ends the timer
	 */
	public void endTimer() {
		endTime = System.nanoTime();
	}
	/**
	 * Returns the elapsed time
	 * @return a String containing the number of seconds of execution
	 */
	
	public String getElapsedTime() {
		return ((endTime - startTime)/1000000000)+" seconds";
	}
	
	public float getElapsedTimeValue(){
		return ((endTime - startTime)/1000000000);
	}
	
	public void resetTimer(){
		startTime =0;
		endTime =0;
	}

}
